<?php


namespace app\admin\controller;


use app\admin\service\ArticleService;
use app\admin\service\CategoryService;
use app\admin\service\PageService;
use app\admin\service\TagService;
use app\BaseController;
use think\facade\Cookie;
use think\facade\View;

class Main extends BaseController
{
    public function index (): string
    {
        // 模板输出
        $data['nickname'] = Cookie::get("nickname");
        return View::fetch('index', $data);
    }

    /**
     * @return string
     * @throws \think\db\exception\DbException
     */
    public function home (): string
    {
        $data['categoryTotal'] = app()->make(CategoryService::class)->queryCount();
        $data['articleTotal'] = app()->make(ArticleService::class)->queryCount();
        $data['tagTotal'] = app()->make(TagService::class)->queryCount();
        $data['pageTotal'] = app()->make(PageService::class)->queryCount();
        // 模板输出
        return View::fetch('home', $data);
    }
}